package cm.day13.Test2;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static void main(String[] args) throws IOException {
//创建服务端
        ServerSocket ss = new ServerSocket(10086);
        //获取网络输入流
        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        //转化为高效流
        DataInputStream dis = new DataInputStream(is);
        //读取数据
        String s = dis.readUTF();
        System.out.println(s);
        //回写数据
        OutputStream ops=accept.getOutputStream();
        DataOutputStream dps=new DataOutputStream(ops);
        dps.writeUTF("写数据完毕");
        //释放资源
        accept.close();
        ss.close();
    }

}
